# Uncomment the next line to define a global platform for your project
source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'

platform :ios, '15.0'

target 'Agent-cn' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!
  
  pod 'Kingfisher'
  pod 'SSZipArchive'
  pod 'SwiftyBeaver', '1.9.5'
  pod 'ZSwiftBaseLib', '0.1.6.2'
  pod 'Bugly'
#  pod 'AgoraRtcEngine_iOS', :path => 'sdk.podspec'
  pod 'AgoraRtcEngine_iOS', '4.5.1'
  #pod 'LookinServer', :subspecs => ['Swift'], :configurations => ['Debug']
  
  pod 'Common', :path => 'Common'

  # Agents
  pod 'ConvoAI', :path => 'Scenes/ConvoAI/ConvoAI'
  pod 'IoT', :path => 'Scenes/ConvoAI/IoT'
  pod 'BLEManager', :path => 'Scenes/ConvoAI/BLEManager'
  pod 'AgoraRtm', :path => 'AgoraRtm.podspec'

end

post_install do |installer|
  resource_url = "https://accktvpic.oss-cn-beijing.aliyuncs.com/ConvoAI/Resource/Convo_AI_Demo_v1.0.0_Resource.zip"
  download_path = "#{Dir.pwd}/Agent/Resources/Convo_AI_Demo_v1.0.0_Resource.zip"
  extract_path = "#{Dir.pwd}/Agent/Resources"
  
  Pod::UI.puts "Downloading Convo AI Demo resources..."
  download_success = system "curl -L #{resource_url} -o #{download_path}"
  
  unless download_success
    Pod::UI.warn "[!] Resource download failed. Please check your network connection and try again."
    raise Pod::Informative, "Resource download failed"
  end
  
  if File.exist?(download_path)
    Pod::UI.puts "Download completed successfully."
    
    Pod::UI.puts "Extracting resources..."
    extract_success = system "unzip -j -o #{download_path} -d #{extract_path}"
    
    unless extract_success
      Pod::UI.warn "[!] Resource extraction failed."
      raise Pod::Informative, "Resource extraction failed"
    end
        
    system "rm #{download_path}"
    
    Pod::UI.puts "Resource settings completed."
  else
    Pod::UI.warn "[!] Resource download failed. Please check your network connection and try again."
    raise Pod::Informative, "Resource download failed"
  end
  
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      # Additional post-install configuration can be added here.
    end
  end
end
